package com.hz.ruoyistorage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hz.ruoyistorage.domain.LgSubCold;
import com.hz.ruoyistorage.domain.mypojo.LgSubColdSome;
import com.hz.ruoyistorage.mapper.LgSubColdMapper;
import com.hz.ruoyistorage.mapper.LgSubColdSomeMapper;
import com.hz.ruoyistorage.service.LgSubColdSomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author gj
 * @Date 2025/3/6 9:59
 * @注释
 */
@Service
public class LgSubColdSomeServiceImpl
        extends ServiceImpl<LgSubColdSomeMapper, LgSubColdSome>
        implements LgSubColdSomeService {
    @Autowired
    private LgSubColdSomeMapper lgSubColdSomeMapper;
    @Autowired
    private LgSubColdMapper lgSubColdMapper;
    @Override
    public List<LgSubColdSome> getAll(Map<String, Object> some) {
        return lgSubColdSomeMapper.getAll(some);
    }

    @Override
    public Integer getTotal(Map<String, Object> some) {
        return lgSubColdSomeMapper.getTotal(some);
    }

    //遍历修改价格
    @Override
    public List<LgSubColdSome> updateDailyPrice(List<LgSubColdSome> lgSubColdSomeList) {
        for (LgSubColdSome lgSubColdSome : lgSubColdSomeList) {
            //算钱
            Double firstNum = 0.0;
            Double secondNum = 0.0;
            //获得容积
            if (lgSubColdSome.getCapacity()!=null){
                firstNum = lgSubColdSome.getCapacity();
            }
            //获得单价
            if (lgSubColdSome.getPriceMeter()!=null){
                secondNum = lgSubColdSome.getPriceMeter();
            }
            lgSubColdSome.setDailyPrice(firstNum*secondNum);
            LgSubCold lgSubCold = new LgSubCold();
            lgSubCold.setSubId(lgSubColdSome.getSubId());
            lgSubCold.setDailyPrice(firstNum*secondNum);
            lgSubColdSome.setDailyPrice(lgSubCold.getDailyPrice());
            lgSubColdMapper.updateDailyPriceById(lgSubCold);
        }
        return lgSubColdSomeList;
    }

    @Override
    public List<LgSubColdSome> getSubAndCamera(Map<String, Object> some) {
        return lgSubColdSomeMapper.getSubAndCamera(some);
    }

    @Override
    public List<LgSubColdSome> getSubAndMachine(Map<String, Object> some) {
        return lgSubColdSomeMapper.getSubAndMachine(some);
    }
}
